home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / General / SC++ 7.0.2 Update / TCL Demos / Process Monitor ƒ / Source / CProcessArrayPane.cp
Encoding:
Text File  |  1994-04-19  |  4.0 KB  |  148 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.  CProcessArrayPane.c
  3.  
  4.                 CProcessArrayPane ArrayPane Class
  5.     
  6.     Copyright © 1994 Chris Prinos, Symantec Corp.. All rights reserved.
  7.  
  8.     Generated by Visual Architect™ 11:44 AM Sun, Mar 13, 1994
  9.  
  10.     This file is only generated once. You can modify it by filling
  11.     in the placeholder functions and adding any new functions you wish.
  12.  
  13.     If you change the name of the document class, a fresh version of this
  14.     file will be generated. If you have made any changes to the file
  15.     with the old name, you will have to copy those changes to the new
  16.     file by hand.
  17.  
  18.  ******************************************************************************/
  19.  
  20. #include "CProcessArrayPane.h"
  21. #include <strings.h>
  22.  
  23. TCL_DEFINE_CLASS_D1(CProcessArrayPane, x_CProcessArrayPane);
  24.  
  25. /**** C O N S T R U C T I O N / D E S T R U C T I O N   M E T H O D S ****/
  26.  
  27.  
  28. /******************************************************************************
  29.  PutTo
  30.  
  31.         Put the contents of this object to the stream
  32.  ******************************************************************************/
  33.  
  34. void    CProcessArrayPane::PutTo(
  35.     CStream     &aStream)
  36. {
  37.         // Put any additional data members for this class
  38.         // before calling the superclass PutTo.
  39.  
  40.         // If you have no additional data members, the
  41.         // PutTo and GetFrom functions can be eliminated.
  42.  
  43.     x_CProcessArrayPane::PutTo(aStream);        /* Let superclass save                */
  44.     
  45.         // By convention, any subordinate objects are put
  46.         // after the superclass has had a chance to write
  47.         // its instance variables.
  48. }
  49.  
  50.  
  51. /******************************************************************************
  52.  GetFrom
  53.  
  54.         Get the contents of this object from the stream and
  55.         initialize the object
  56.  ******************************************************************************/
  57.  
  58. void    CProcessArrayPane::GetFrom(
  59.     CStream     &aStream)
  60. {
  61.         // Get any additional data members for this class
  62.         // before calling the superclass GetFrom
  63.  
  64.  
  65.                                         /* Let superclass restore            */
  66.     x_CProcessArrayPane::GetFrom(aStream);
  67.  
  68.         // Restore any subordinate objects below
  69.         
  70. // ••••• Visual Architect Tutorial Code Change Begin •••••
  71.     // assign the apps process
  72.     // list as the one to use for this
  73.     // array pane
  74.     fCurrentMode = byName;
  75.     SetArray( ((CApp *)gApplication)->fProcessList, false); 
  76. // ••••• Visual Architect Tutorial Code Change End •••••
  77. }
  78.  
  79. // ••••• Visual Architect Tutorial Code Change Begin •••••
  80. // GetCellText(Cell, short, StringPtr)            
  81. //
  82. //    Tells CProcessArrayPane how to draw it's cells. Each cell will display
  83. //     the name, signature, or PSN of the corresponding CProcess object.
  84. //  Whatever the mode, the final result gets stuffed into itsText so that
  85. //  the table can display the appropriate string
  86. //
  87. void CProcessArrayPane::GetCellText( Cell aCell, short availableWidth, StringPtr itsText)
  88. {
  89.     CProcess *proc;
  90.  
  91.     itsArray->GetArrayItem(&proc, aCell.v+1);
  92.     
  93.     switch(fCurrentMode)    // display according to current view mode
  94.     {
  95.         case byName:        
  96.             CopyPString (proc->GetProcessName(), itsText);
  97.             break;
  98.             
  99.         case byPSN:
  100.             ProcessSerialNumber PSN = proc->GetPSN();
  101.             Str255 PSNString;
  102.             sprintf((char *)PSNString, "%.4lu%.4lu",PSN.highLongOfPSN, PSN.lowLongOfPSN);
  103. #ifdef TCL_POWER_PC
  104.             c2pstr((char *)PSNString);
  105. #else
  106.             CtoPstr((char *)PSNString);
  107. #endif
  108.             CopyPString( PSNString, itsText);
  109.             break;
  110.             
  111.         case bySig:
  112.             long    sig;        
  113.             itsText[0] = 6;
  114.             itsText[1] = '\'';
  115.             itsText[6] = '\'';
  116.             sig = proc->GetSignature();
  117.             * ((long*)&itsText[2]) = sig;
  118.             break;
  119.     }        
  120.     
  121. }    
  122.  
  123. // GetProcessItem
  124. //
  125. //    Given a index number of the ProcessArrayPanes process list, 
  126. //    return a pointer to the CProcess at that position.
  127. //    
  128. const CProcess    *CProcessArrayPane::GetProcessItem(long index) const
  129. {
  130.     CProcess *proc;
  131.     
  132.     itsArray->GetArrayItem(&proc, index);
  133.     return proc;
  134. }
  135.  
  136.  
  137. // ChangeView
  138. //
  139. // Set the display mode for this CProcessArrayPane. This decides the format
  140. // that processes are displayed in.
  141. //
  142. void CProcessArrayPane::ChangeView(ProcessDisplayMode newMode)
  143. {
  144.     fCurrentMode = newMode;
  145. }
  146.  
  147. // ••••• Visual Architect Tutorial Code Change End •••••
  148.